#include "pch.h"
#include "DrawCell.h"
#include "LightActor.h"
#include "Camera.h"

namespace mini
{
	void DrawCell::apply()
	{
		if (nullptr != pShader)
		{
		//	pShader->use();
		}
	}

	void WVPDrawCell::apply()
	{
		if (nullptr != pActor)
		{
			pShader->updateVSConstBuffer(0, matrixArray, 0);
		}
	}

	void LightDrawCell::apply()
	{
		if (nullptr != pActor)
		{
			CLightActor* pLight = dynamic_cast<CLightActor*>(pActor);
			if (nullptr != pLight)
			{
				ambientColor = pLight->getAmbientColor();
				diffuseColor = pLight->getDiffuseColor();
				specularColor = pLight->getSpecularColor();
				lightDirection = pLight->getDirection();
				pShader->updateVSConstBuffer(pLight->getRegister(), &pLight->getAmbientColor(), 0);
			}
		}
	}

	void RefractionDrawCell::apply()
	{
		if (nullptr != pActor)
		{
			pShader->updateVSConstBuffer(5, &clipPlane, 0);
		}
	}

	void ReflectionDrawCell::apply()
	{
		if (nullptr != pActor)
		{
			CCamera* pCamera = dynamic_cast<CCamera*>(pActor);
			if (nullptr != pCamera)
			{
				matrix = pCamera->getViewMatrix();
				pShader->updateVSConstBuffer(5, &matrix, 0);
			}
		}
	}

}
